package leetcode122

func maxProfit(prices []int) (res int) {
	for i := 1; i < len(prices); i++ {
		res += max(0, prices[i]-prices[i-1])
	}
	return
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}
